package cn.craftyun.serverlist.controller;

import cn.craftyun.serverlist.exception.ServiceFailedException;
import cn.craftyun.serverlist.vo.ResultEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 服务异常处理
     *
     * @param e 异常对象
     * @return 错误消息
     */
    @ExceptionHandler(ServiceFailedException.class)
    public ResultEntity<Void> handleServiceFailed(Exception e) {
        return ResultEntity.failed(e.getMessage());
    }
}
